# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Daniel Bermond <dbermond@archlinux.org>
# Contributor: Chocobo1 <chocobo1@archlinux.net>

pkgname=rav1e
pkgver=0.4.1
pkgrel=1
pkgdesc='An AV1 encoder focused on speed and safety'
arch=(x86_64)
url=https://github.com/xiph/rav1e/
license=(BSD)
depends=(
  gcc-libs
  glibc
)
makedepends=(
  cargo-c
  git
  nasm
  rust
)
provides=(librav1e.so)
_tag=29a9c604879bc27d319edc03e2c97ba9e9628c86
source=(git+https://github.com/xiph/rav1e.git#tag=${_tag})
sha256sums=(SKIP)

pkgver() {
  cd rav1e

  git describe --tags | sed 's/^v//'
}

prepare() {
  cargo fetch \
    --locked \
    --manifest-path rav1e/Cargo.toml
}

build() {
  cargo build \
    --release \
    --frozen \
    --manifest-path rav1e/Cargo.toml
  cargo cbuild \
    --release \
    --frozen \
    --prefix=/usr \
    --manifest-path rav1e/Cargo.toml
}

check() {
  cargo test \
    --release \
    --frozen \
    --manifest-path rav1e/Cargo.toml
}

package() {
  cd rav1e

  cargo install \
    --frozen \
    --offline \
    --no-track \
    --path . \
    --root "${pkgdir}"/usr
  cargo cinstall \
    --release \
    --frozen \
    --prefix /usr \
    --destdir "${pkgdir}"
  install -Dm 644 LICENSE PATENTS -t "${pkgdir}"/usr/share/licenses/rav1e/
}

# vim: ts=2 sw=2 et:
